import java.io.*;
import java.net.*;

public class ftpbytcp
{
	public static void main(String arg[])throws IOException
	{
		try{
		Socket sock=new Socket("127.0.0.1",7070);
		BufferedReader x,br;
		OutputStream out;
		InputStream in;
		out=sock.getOutputStream();
		in=sock.getInputStream();
		br=new BufferedReader(new InputStreamReader(in));
		PrintStream pr=new PrintStream(out);
		System.out.println("enter the shell command to execute at both client and server side");
		x=new BufferedReader(new InputStreamReader(System.in));
		String str=x.readLine();
		pr.println(str);
		Process p=Runtime.getRuntime().exec(str);
		BufferedReader prin =new BufferedReader(new InputStreamReader(p.getInputStream()));
		String line="";
		while((line=prin.readLine())!=null)
			System.out.println(""+line);
		String response=br.readLine();
		System.out.println(""+response);
		}
		catch(Exception e)
		{
			System.out.println(""+e);
		}
	}
}
